home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / dvips / header.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-01-05  |  1.8 KB  |  77 lines

  1. /*
  2.  *   This routine handles the PostScript prologs that might
  3.  *   be included through:
  4.  *
  5.  *      - Default
  6.  *      - Use of PostScript fonts
  7.  *      - Specific inclusion through specials, etc.
  8.  *      - Use of graphic specials that require them.
  9.  *
  10.  *   Things are real simple.  We build a linked list of headers to
  11.  *   include.  Then, when the time comes, we simply copy those
  12.  *   headers down.
  13.  */
  14. #include "structures.h" /* The copyright notice in that file is included too! */
  15. struct header_list {
  16.    char *name ;
  17.    struct header_list *next ;
  18. } *header_head ;
  19. /*
  20.  *   The external routines we use.
  21.  */
  22. extern char *malloc() ;
  23. extern char *newstring() ;
  24. extern void error() ;
  25. extern void copyfile() ;
  26. #ifdef DEBUG
  27. extern integer debug_flag ;
  28. #endif
  29. /*
  30.  *   This routine is responsible for adding a header file.
  31.  */
  32. void
  33. add_header(s)
  34.    char *s ;
  35. {
  36.    struct header_list *p, *q ;
  37.  
  38.    for (p = header_head ; p != NULL; p = p->next)
  39.       if (strcmp(p->name, s)==0) {
  40. #ifdef DEBUG
  41.          if (dd(D_HEADER))
  42.             (void)fprintf(stderr, "Header file \"%s\" already in list\n", s) ;
  43. #endif
  44.          return ;
  45.       }
  46.    q = (struct header_list *)malloc((unsigned)sizeof(struct header_list)) ;
  47.    if (q==NULL)
  48.       error("! out of memory") ;
  49.    q->next = NULL ;
  50.    q->name = newstring(s) ;
  51. #ifdef DEBUG
  52.    if (dd(D_HEADER))
  53.       (void)fprintf(stderr, "Adding header file \"%s\"\n", s) ;
  54. #endif
  55.    if (header_head == NULL)
  56.       header_head = q ;
  57.    else {
  58.       for (p=header_head; p->next != NULL; p = p->next) ;
  59.       p->next = q ;
  60.    }
  61. }
  62. /*
  63.  *   This routine actually sends the headers.
  64.  */
  65. void
  66. send_headers() {
  67.    struct header_list *p ;
  68.  
  69.    for (p=header_head; p!=NULL; p = p->next) {
  70. #ifdef DEBUG
  71.       if (dd(D_HEADER))
  72.          (void)fprintf(stderr, "Sending header file \"%s\"\n", p->name) ;
  73. #endif
  74.       copyfile(p->name) ;
  75.    }
  76. }
  77.